# Maintainer: Alexander F. Rødseth <xyproto@archlinux.org>
# Contributor: Tobias Powalowski <tpowa@archlinux.org>

pkgname=camlp4
_ocaml_ver=5.0.0
pkgver=${_ocaml_ver%.*}+1
pkgrel=1
pkgdesc='Caml preprocessor and pretty-printer'
arch=(loong64 x86_64)
license=(GPL2)
url='https://github.com/ocaml/camlp4/releases'
depends=("ocaml")
makedepends=(git ocamlbuild ocaml-compiler-libs ocaml-findlib camlp-streams)
options=(!makeflags !emptydirs staticlibs)
_ocaml_5_commit=862936ff67fe01f8e2e35e667e4a7f2990ebc300
source=("$pkgname-$pkgver.tar.gz::https://github.com/ocaml/camlp4/archive/${_ocaml_5_commit}.tar.gz")
b2sums=('74cdc24c957f826778546121555ef2914330d1da5fea8eef83b7c183f779f62fc2f20fece533e4dff3102495252dcaa07680358aeb0f7449899d91b891dbbbcf')
build() {
  cd "$pkgname-${_ocaml_5_commit}"
  CFLAGS+=' -ffat-lto-objects -w'
  ./configure
  make all camlp4/META
}

package() {
  cd "$pkgname-${_ocaml_5_commit}"
  make \
    BINDIR="$pkgdir/usr/bin" \
    LIBDIR="$pkgdir/usr/lib/ocaml" \
    PKGDIR="$pkgdir/usr/lib/ocaml" \
    install install-META
}
